<include file='Public/head' />
<include file='Public/header1' />

		<!--头部开始-->
		<div class="p_header">
			<div class="main">
				<div class="p_logo">
					<a href="#"><img src="__IMG__//13.png"/></a>
				</div>
				<div class="p_title"></div>
			</div>
		</div>
		<!--头部结束-->
		<style type="text/css">
			.hidden-in{
				position: relative;
				z-index:-1;
			}
			.uploadify-button {
			    color: #2CBDBD;
			    cursor: pointer;
			    position: relative;
			    text-align: center;
				left: -50px;
			}
			form input[type=button]{margin-left: 100px;background: #f0b848;border-radius: 5px;font-size: 18px; font-weight: 800;color: #333;}
		</style>
		<!--导航开始-->
		<div class="main">
			<div class="nav">
				<ul>
					<li><a href="#">我的课程</a></li>
					<li><a href="#" style="color: #2CBDBD; border-bottom:4px solid #2CBDBD;">我的信息</a></li>
					<li><a href="#" >我的学习</a></li>
					<li><a href="#">我的收藏</a></li>
					<li><a href="#">我的订单</a></li>
					<li><a href="#">我的同学</a></li>
					<li><a href="#">我的分享</a></li>
					<li><a href="#">我的任务</a></li>
					<li><a href="#">课程勘误</a></li>
					<li><a href="#">学习笔记</a></li>
				</ul>
			</div>
		</div>
		<!--	导航结束-->
		<div class="border_b1"></div>
		<div class="main_border">
			<div class="per_title">
				<ul>
					<li><a href="#">个人信息</a></li>
					<li><a href="#">账号设置</a></li>
					<li><a href="#">发票管理</a></li>
					<li><a href="#">积分等级</a></li>
					<li><a href="#">优惠中心</a></li>
					<li><a href="#">我的任务</a></li>
				</ul>
			</div>
<style type="text/css">
	.face_l img{
		    width: 100px;
		    height: 100px;
	}
</style>
		<div class="main_2">
			<div class="main_3">
				<div class="face">
					<div class="face_n">头像: </div>
						<div class="face_in">
							<div class="face_l"><img id='userhead' src="{$info['userhead'] | default='/Public/Home/images/defaultuser.jpg'}"  alt=""></div>
							<div class="face_r">
								<div class="">
									<p>支持jpg、gif、png或bmp格式的图片，文件须小于1M</p>
									<input type="file" name='userhead' id='uploadfile' class='hidden-in' accept="jpg,gif,png,bmp">
								</div>
							</div>
						</div>
					</div>
					<!--头像结束-->
					<form action="{:U()}" id='theform' onsubmit="submit(e);return false ;">
						<div class="form-group">
							<label for="">昵称</label>
							<input type="text" name='nickname' value="{$info.nickname|default=''}" placeholder="请输入昵称3-6个字" />
						</div>
						<div class="form-group">
							<label for="">真实姓名</label>
							<input type="text" name='real_name' value="{$info.real_name|default=''}"  placeholder="请输入真实姓名" />
						</div>
						<div class="form-group">
							<label for="">身份证号码</label>
							<input type="text" name='idcard' value="{$info.idcard|default=''}" maxlength="18" placeholder="请输入18位身份证号" />
						</div>
						<div class="form-group">
							<label for="">联系方式</label>
							<div class="num">{$info.username|replacename|}</div>
						</div>
						<div class="form-group radio_g" >
							<label for="">性　　别</label>
									<input type="radio" name="sex" value="1" <eq name='info.sex' value='1'>checked</eq> class="radio"/ > <span class="span1">男</span>
									<input type="radio" name="sex" value="2" <eq name='info.sex' value='2'>checked</eq>   class="radio"/ > <span class="span2">女</span>
						</div>
						<div class="form-group">
							<label for="">出生日期</label>
							<select class="sel_year default" rel="<notempty name='info.year'>{$info.year}<else />{:date('Y')}</notempty>" name='year' tabindex="1"> </select> 
							<select class="sel_month default" rel="<notempty name='info.month'>{$info.month}<else />{:date('m')}</notempty>" name='month' tabindex="1"> </select> 
							<select class="sel_day default" rel="<notempty name='info.day'>{$info.day}<else />{:date('d')}</notempty>" tabindex="1" name='day'> </select> 
						</div>
						<div class="form-group">
							<label for="">收货地址</label>
							<select name="region1" id="region1" onchange='get_area(this.value , "region2")'>
							</select>
							<select name="region2" id="region2">
							</select>
						</div>
						<div class="form-group">
							<label for="">详细地址</label>
							<input type="text" name='detail' placeholder="详细地址" value="{$info.detail}"  />
						</div>
						<div class="form-group">
							<notempty name='info.addressid'>
								<input type="hidden" name='addressid' value="{$info.addressid}">
							</notempty>
							<input type="button" id="submit"  value="保存"/>
						</div>
					</form>
				</div>
			</div>	
		</div>
	<include file='Public/commonfooter' /> 
	<script type="text/javascript" src="__STATIC__/birth.js"></script>
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<script>
			$(function () { 
				    $.ms_DatePicker({ 
				            YearSelector: ".sel_year", 
				            MonthSelector: ".sel_month", 
				            DaySelector: ".sel_day" 
				    });

				    //加载收货地址。　
				    get_area('0' , 'region1' , '{$info.region1|default=0}');
				    get_area('{$info.region1}' , 'region2' , '{$info.region2|default=0}');
				}); 
			$('#upload').on('click' , function(){
				$('#uploadfile').click();
			})
			$('#uploadfile').on('change' , function(){
				 $('#uploadfile').uploadify({
		            'swf'      : '__STATIC__/uploadify/uploadify.swf',    //指定上传控件的主体文件
		            'uploader' :  '{:U("Public/changehead")}',  //指定服务器端上传处理文件
		            'auto' : true ,
		       		'fileTypeExts' : 'jpg,png,gif,jpeg,bmp',
		       		'onUploadSuccess' : function(){
		       			console.log(1);
		       		}
		        });
			});

			$("#uploadfile").uploadify({
			        "height"          : 30,
			        "swf"             : "__STATIC__/uploadify/uploadify.swf",
			        "fileObjName"     : "userhead",
			        "buttonText"      : "上传头像",
			        "uploader"        : "{:U('Public/changehead')}",
			        "width"           : 120,
			        'removeTimeout'	  : 1,
			        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
			        "onUploadSuccess" : uploadPicture,
			        'onFallback' : function() {
			            alert('未检测到兼容版本的Flash.');
			        }
			    });

			function uploadPicture(e , data){
				data = JSON.parse(data);
				console.log(data);
				if(data.status){
					$('#userhead').attr('src' , data.url);
				}
				msg(data.info);
			}
		
		//
		function get_area(val , emel , select_id ){
			$.getJSON('{:U("Home/Public/get_child_region")}&pid='+val , function(data){
				html = '';
				$.each(data.data , function(i,v){
					html += '<option value='+v.id+'>'+v.name+'</option>';
				});
				$('#' + emel).empty().html(html);
				(select_id > 0) && $('#' + emel).val(select_id);
			});
		}
		$('#submit').on('click' , function(e){
			e.preventDefault();
			var url = $('#theform').attr('action');
			$.post(url , $('#theform').serialize() , function(data){
				layer.msg(data.info);
				setTimeout(function(){
					window.location.reload();
				} , 1500);
			});
			return false ;
		});
	</script>
	
	</body>
</html>

